From f483c5b7d635e15373c4fe61c96de3410d299a32 Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Sat, 5 Sep 2009 16:41:09 +0200 Subject: [PATCH] Emit row-has-child-toggled when a first node becomes visible in a level If we have a level with zero visible nodes and the first node becomes visible in that level, then parent has just become a "real" parent node. In such a case we need to emit row-has-child-toggled. This only applies to non-root levels that have a parent. This problem was also found when writing the unit test, the respective cases in the unit test have been corrected. This fixes bugs: Bug 372010 - Filtering not working properly Bug 525965 - Filtered and sorted GtkTreeView is missing rows --- gtk/gtktreemodelfilter.c | 15 +++++++++++++++ gtk/tests/filtermodel.c | 7 +++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c index 103663606c..2dd41ef7f2 100644 --- a/gtk/gtktreemodelfilter.c +++ b/gtk/gtktreemodelfilter.c @@ -1336,6 +1336,21 @@ gtk_tree_model_filter_row_changed (GtkTreeModel *c_model, gtk_tree_model_row_inserted (GTK_TREE_MODEL (filter), path, &iter); + if (level->parent_level && level->visible_nodes == 1) + { + /* We know that this is the first visible node in this level, so + * we need to emit row-has-child-toggled on the parent. This + * does not apply to the root level. + */ + + gtk_tree_path_up (path); + gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), &iter, path); + + gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (filter), + path, + &iter); + } + if (gtk_tree_model_iter_children (c_model, &children, c_iter)) gtk_tree_model_filter_update_children (filter, level, elt); } diff --git a/gtk/tests/filtermodel.c b/gtk/tests/filtermodel.c index 52e0d5102b..4a31aa3ddd 100644 --- a/gtk/tests/filtermodel.c +++ b/gtk/tests/filtermodel.c @@ -856,8 +856,9 @@ filled_hide_child_levels (FilterTest *fixture, check_level_length (fixture->filter, "0:3", LEVEL_LENGTH); check_level_length (fixture->filter, "0:4", 0); - /* FIXME: We are missing a row-has-child-toggled signal for path "0:4" */ signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:0"); + /* Once 0:4:0 got inserted, 0:4 became a parent */ + signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4"); signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4:0"); signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:1"); signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4:1"); @@ -1048,11 +1049,12 @@ filled_vroot_hide_child_levels (FilterTest *fixture, check_level_length (fixture->filter, "0:3", LEVEL_LENGTH); check_level_length (fixture->filter, "0:4", 0); - /* FIXME: We are missing a row-has-child-toggled signal for path "0:4" */ /* FIXME: Inconsistency! For the non-vroot case we also receive two * row-has-child-toggled signals here. */ signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:0"); + /* Once 0:4:0 got inserted, 0:4 became a parent */ + signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4"); signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:1"); set_path_visibility (fixture, "2:0:4:2", TRUE); set_path_visibility (fixture, "2:0:4:4", TRUE); @@ -1080,6 +1082,7 @@ empty_show_nodes (FilterTest *fixture, check_level_length (fixture->filter, "0", 0); signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:0"); + signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0"); signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:0"); set_path_visibility (fixture, "3:2", TRUE); check_filter_model (fixture); -- 2.30.2